{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class="active"><a href="javascript:;">奖品管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('luckAddGood', array('op' => 'addShow', 'luckId' => $luck_id));}">添加商品</a></li>
</ul>

<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th>id</th>
                <th>类型</th>
                <th>金额</th>
                <th>抽奖商品</th>
                <th>图片</th>
                <th>份数</th>
                <th>提供方式</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $luckGoods['list'] $item}
            <tr class="odd gradeX">
                <td>{$item['id']}</td>
                <td>{$item['type']}</td>
                <td>{$item['red_money']}</td>
                <td>{$item['name']}</td>
                <td><img src="{php echo tomedia($item['image'])}" style="width:60px; height: 40px"></td>
                <td>{$item['number']}</td>
                <td>{php echo $item['source'] ==1 ? '发起者提供' : '商城奖品'}</td>
                <td>{php echo date('Y-m-d H:i:s',$item['created'])}</td>
                <td>
                    <a href="{php echo $this->createWeburl('checkGoodsDetails', array('column' => 'luck', 'behavior' => 'assign', 'id'=>$item['luck_id']));}" class="btn btn-success btn-sm">查看/指定</a>
                    <a href="javascript:;" data-id="{$item['id']}" class="btn btn-danger btn-sm del">删除</a>

                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
    {$pager}
</div>
<script type="application/javascript">
    $(function () {
        $('.del').click(function () {
            if (!confirm('确认要删除该商品')) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'delete'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });

        $('.is_down').click(function () {
            if (!confirm('确认要' + $(this).html())) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'down'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('设置失败');
                }

            }, 'json')
        });

        $('.settop').click(function () {

            id = $(this).data('id');
            $.post('', {id:id, op:'settop'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });
    });

</script>